// hyb_yl/pharmacy/pages/evaluate/evaluate.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab_index:0,
    lab_index:0,
    list:[],
    hid:"",
    page:0,
  },
  tab_btn:function(e){
    this.setData({
      tab_index:e.currentTarget.dataset.index
    })
  },
  lab_btn:function(e){
    this.setData({
      lab_index:e.currentTarget.dataset.index,
      page:0,
      list:[]
    })
    this.getpingjia();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var hid = options.hid;
    var agentname = options.agentname;
    var that = this;
    that.setData({
      hid:hid
    })
    wx.setNavigationBarTitle({
      title: agentname,
    })
    that.getHospital();
    that.getpingjia();
  },
  // 获取药房详情
  getHospital:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/Goods.hospital_detail",
      data:{
        hid:that.data.hid
      },
      success:function(res){
        that.setData({
          info:res.data
        })
      }
    })
  },
  // 获取评价
  getpingjia:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/Goods.hos_pingjia",
      data:{
        hid:that.data.hid,
        lab_index:that.data.lab_index,
        page:that.data.page
      },
      success:function(res){
        var page = that.data.page + 1;
        that.setData({
          page:page,
          list:that.data.list.concat(res.data)
        })
      }
    })
  },
  // 导航
  toaddress:function(e){
    wx.openLocation({
      latitude: parseFloat(e.currentTarget.dataset.latitude),
      longitude: parseFloat(e.currentTarget.dataset.longitude),
      address: e.currentTarget.dataset.address+e.currentTarget.dataset.xxaddress,
      scale: 22
    });
  },
  // 拨打电话
  tocall:function(e){
    var phone = e.currentTarget.dataset.telphone
    wx.makePhoneCall({
      phoneNumber: phone,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getpingjia();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})